using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Be.Timvw.Framework.Domain.Effectivity
{
    /// <summary>
    /// Specifications for the retrieval of a snapshot from a temporal object.
    /// </summary>
    [TestClass]
    public class WhenGettingSnapshotFromTemporal : TemporalUnitTest
    {
        /// <summary>
        /// When there is an effectivity on the given date, it should be returned.
        /// </summary>
        [TestMethod]
        public void ShouldReturnEffectivityWhenEffectivityExists()
        {
            ITemporal<string> effectivityManager = Create();
            DateTime validityDate = new DateTime(2000, 1, 15);
            IEffectivity<string> actualEffectivity = effectivityManager.GetSnapshot(validityDate);
            Assert.AreEqual(InitialTemporalValue, actualEffectivity.Element);
        }

        [TestMethod]
        [ExpectedException(typeof(ArgumentOutOfRangeException))]
        public void ShouldThrowWhenEffectivityDoesNotExist()
        {
            ITemporal<string> effectivityManager = Create();
            DateTime validityDate = new DateTime(1999, 1, 15);
            effectivityManager.GetSnapshot(validityDate);
        }
    }
}